<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link rel="stylesheet" href="https://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.css">
		<script src="https://apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script>
		<script src="https://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
		<title>二手交易系统</title>
		<script type="text/javascript">
			/* document.addEventListener('plusready', function(){
   			//console.log("所有plus api都应该在此事件发生后调用，否则会出现plus is undefined。")
   			
   		}); */
		</script>
		<!-- 控制头部和底部导航样式 -->
		<link rel="stylesheet" type="text/css" href="css/style.css"/>
		<script>
			//若用户未登录，则需先登录
			var logstatu = sessionStorage['LoginName'];
			console.log("name is "+name);
			console.log("statu is "+logstatu);
			if (!logstatu) {
				location.href = 'c_login.html';
				console.log(logstatu);
			}
		</script>
		<script src="js/login/register.js"></script>
		<script>
		var user = getUser();
		</script>
		<script>
		//读取url获取，具体传递的数据
		function getQueryVariable(variable) {
			var query = window.location.search.substring(1);
			var vars = query.split("&");
			for (var i = 0; i < vars.length; i++) {
				var pair = vars[i].split("=");
				if (pair[0] == variable) {
					return pair[1];
				}
			}
			return (false);
		}
		
		//获取地址详情
		var addrID = getQueryVariable("id");
		var addressObj=user.addr[addrID];
		

		</script>
		<script>$.mobile.ajaxEnabled = false;</script>
	</head>
	<body>

		<div data-role="page">
			<div data-role="header" data-position="fixed" id="opcitybg">
				<a id="headop" href="#" data-role="button" data-rel="back" data-icon="carat-l" data-iconpos="notext"></a>
				<h1>地址详情</h1>
				<a id="headop" href="#" data-role="button" data-icon="plus" data-iconpos="notext"></a>
			</div>
			​
			<div data-role="main" class="ui-content">
				<script>
				document.write(
				'<ul data-role="listview" data-inset="true">'+
						'<li data-icon="false">'+
							'<a href="#">'+
								'<img src="./img/location.jpg" data-icon="user">'+
								'<h2>'+addressObj.province+'</h2>'+
								'<p>'+ addressObj.detial+'</p>'+
							'</a>'+
						'</li>'+
					'</ul>'+
				
				
					'<form method="post" action="">'+
						'<div class="ui-field-contain">'+
							'<label for="province">省份：</label>'+
							'<input type="text" name="province" id="province" value="'+addressObj.province+'">'+
							'<label for="detial">详细地址:</label>'+
							'<input type="text" name="detial" id="detial" value="'+addressObj.detial+'">'+
							'<label for="tel">Tel:</label>'+
							'<input type="tel" name="tel" id="tel" value="'+addressObj.addrTel+'">'+
						'</div>'+
					'</form>'
					);
				</script>
				


				<ul class="defa" data-role="listview" data-inset="true">
					<li  data-icon="false">
						<a href="#">
							<img src="./img/location.jpg" data-icon="user">
							<h2>江西省南昌市</h2>
							<p>江西省南昌市青山湖区江西财经大学</p>
						</a>
					</li>
				</ul>

				<form class="defa" method="post" action="">
					<div class="ui-field-contain">
						<label for="province">省份：</label>
						<input type="text" name="province" id="province" value="江西省">
						<label for="city">区县：</label>
						<input type="text" name="city" id="city" value="南昌市青山湖区">
						<label for="email">详细地址:</label>
						<input type="text" name="detial" id="detial" value="江西财经大学">
						<label for="tel">Tel:</label>
						<input type="tel" name="tel" id="tel" value="18882022676">
					</div>
				</form>
			</div>



			<div data-role="footer" data-position="fixed" id="footerbg">

				<div data-role="navbar">
					<ul>
						<li><a id="modify" data-icon="check">修改</a></li>
						<li><a href="c_location.html" data-icon="delete">取消</a></li>
					</ul>
				</div>

			</div>
		</div>
		<script>
		//登录之后取消默认显示
		if(user){
			$(".defa").css({
				display:"none",
			})
		}
		
		function updateValue(){
			addressObj.province=$("#province").val();
			addressObj.detial = $("#detial").val();
			addressObj.addrTel = $("#tel").val();
			return addressObj;
		}
		
		//修改数据
		$("#modify").click(function(){
			addressObj =updateValue();
			updateAddr(addrID,addressObj);
		})
		
		</script>


	</body>
</html>
